home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW Related / DTS MPW Goodies / CancelWindowCheckOut < prev    next >
Encoding:
Text File  |  1990-09-14  |  1.8 KB  |  84 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        CancelWindowCheckOut
  3. #
  4. #    Contains:    script to revert to an old copy of a checked-out window
  5. #
  6. #    Usage:        CancelWindowCheckOut window
  7. #
  8. #    Status:        CancelWindowCheckOut may return the following status values:
  9. #
  10. #                    0        the window was reverted
  11. #                    1        error
  12. #                    2        the user canceled
  13. #
  14. #                CancelWindowCheckOut cancels the changes that have been made
  15. #                to a file in a window.
  16. #
  17. #    Written by:    Darin Adler and scott douglass
  18. #
  19. #    Copyright:    © 1988, 1989 by Apple Computer, Inc., all rights reserved.
  20. #
  21. #    Change History:
  22. #
  23. #        11/9/89        dba        twiddled relentlessly
  24. #
  25. #    To Do:
  26. #        a way to start over (get a new modifiable copy)
  27. #        a way to start over but make it a new branch
  28. #
  29.  
  30. Set Exit 0
  31.  
  32. # the following helps to debug until MPW sends echos to Dev:Console instead of Dev:StdErr
  33.  
  34. If {Echo}
  35.     Set somewhere "∑∑ '{Worksheet}'"
  36. Else
  37.     Set somewhere "∑ Dev:Null"
  38. End
  39.  
  40. Begin
  41.  
  42.     Set Window "{1}"
  43.  
  44.     # get short name of window
  45.  
  46.     If "{Window}" !~ /:*([¬:]+:*)*([¬:]+)®1/
  47.         Alert "Can’t parse window parameter."
  48.         Exit 1
  49.     End
  50.     Set Short "{®1}"                    # get short name for dialogs
  51.     Set Cant "Changes to “{Short}” can’t be discarded"
  52.  
  53.     # check what project the window belongs to
  54.  
  55.     Set Info "`ProjectInfo "{Window}"`"
  56.     If "{Info}" !~ /≈Project: (≈∫)®1     Checked out: ≈/
  57.         Alert "{Cant} because it doesn’t belong to a project."
  58.         Exit 1
  59.     End
  60.     Set Project "{®1}"
  61.  
  62.     # ensure that the window is checked out
  63.  
  64.     If "{Info}" !~ /[¬,]+,[¬ ∂t]+∂+≈/
  65.         Alert "{Cant} because it wasn’t checked out."
  66.         Exit 1
  67.     End
  68.  
  69.     # check if the project is mounted
  70.  
  71.     Set Info "`ProjectInfo -only -project "{Project}"; Set InfoStatus {Status}`"
  72.     If {InfoStatus}
  73.         Alert "{Cant} because the project “{Project}” is not mounted."
  74.         Exit 1
  75.     End
  76.  
  77.     CheckOut -project "{Project}" -cancel "{Window}"
  78.     If {Status}
  79.         Alert "I confused: CheckOut -cancel failed!"
  80.         Exit 1
  81.     End
  82.  
  83. End {somewhere}
  84.